package com.winenine999.generator.dao;

import com.winenine999.model.Purchase;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface PurchaseMapper {
    @Delete({
        "delete from purchase",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into purchase (id, name, ",
        "endtime, starttime, ",
        "detail, state)",
        "values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, ",
        "#{endtime,jdbcType=VARCHAR}, #{starttime,jdbcType=VARCHAR}, ",
        "#{detail,jdbcType=VARCHAR}, #{state,jdbcType=INTEGER})"
    })
    int insert(Purchase record);

    int insertSelective(Purchase record);

    @Select({
        "select",
        "id, name, endtime, starttime, detail, state",
        "from purchase",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("com.winenine999.generator.dao.PurchaseMapper.BaseResultMap")
    Purchase selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(Purchase record);

    @Update({
        "update purchase",
        "set name = #{name,jdbcType=VARCHAR},",
          "endtime = #{endtime,jdbcType=VARCHAR},",
          "starttime = #{starttime,jdbcType=VARCHAR},",
          "detail = #{detail,jdbcType=VARCHAR},",
          "state = #{state,jdbcType=INTEGER}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Purchase record);
}